/* NOTE: This do file replicates results from the online appendix */

/* NOTE:  For replication, you must first run ROC.do and ROCclogit.do before running this program. */ 


/* APPENDIX B, TABLE B1: 2 >= CD-INDEX  < 3 */ 

eststo clear
quietly clogit prime_minister largest_party incumbentpm_party median_party if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty_direct prparty_indirect if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty_proactive prparty_reactive if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty_pro_direl prparty_re_direl prparty_pro_parl prparty_re_parl if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
estout, cells(b(star fmt(2)) se(par fmt(2)) ) posthead("") stats(NFO N r2_p ll TPR TP, fmt(0 0 2 3 2 0) label(N-Formation N-Parties Pseudo-R2 Log-likelihood Prediction-rate Outcomes-predicted)) prefoot("") starlevels(* 0.10 ** 0.05 *** 0.001) postfoot("Note: standard errors in parentheses") label legend varlabels(_cons Constant)  


/* APPENDIX B, TABLE B2: CD-INDEX >= 3*/

eststo clear
quietly clogit prime_minister largest_party incumbentpm_party median_party if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty_direct prparty_indirect if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty_proactive prparty_reactive if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
quietly clogit prime_minister largest_party incumbentpm_party median_party prparty_pro_direl prparty_re_direl prparty_pro_parl prparty_re_parl if caretaker==0 & pm_nonparty==0 & cabmajparty==0 & hos_monarch==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & party_name!="Independents", group(cabinet_id)
quietly calcROC_clogit
eststo
estout, cells(b(star fmt(2)) se(par fmt(2)) ) posthead("") stats(NFO N r2_p ll TPR TP, fmt(0 0 2 3 2 0) label(N-Formation N-Parties Pseudo-R2 Log-likelihood Prediction-rate Outcomes-predicted)) prefoot("") starlevels(* 0.10 ** 0.05 *** 0.001) postfoot("Note: standard errors in parentheses") label legend varlabels(_cons Constant)  


/* APPENDIX C, TABLE C1 - Independent PMs & Monarchies */

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0 & cd_index > 1 & cd_index < 2

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0 & cd_index >= 2 & cd_index < 3

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0 & cd_index >= 3


/* APPENDIX C, TABLE C2: Independent PMs & Monarchies, post-1990 */

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0 & start_year>=1990

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0 & cd_index > 1 & cd_index < 2 & start_year>=1990

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0 & cd_index >= 2 & cd_index < 3 & start_year>=1990

tab prime_minister largest_party if prime_minister  & caretaker==0 & cabmajparty==0 & hos_interim==0 & pr_nonparty==0 & cd_index >= 3 & start_year>=1990


/* APPENDIX C, TABLE C3: 2 >= CD-INDEX  < 3, Independent PMs & Monarchies */

mixlogit prime_minister largest_party median_party if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3, rand(incumbentpm_party ) group(cabinet_id) nrep(200)
calcROC
estimates store model1

mixlogit prime_minister largest_party median_party if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3, rand(incumbentpm_party prparty) group(cabinet_id) nrep(200)
calcROC
estimates store model2
lrtest model2 model1, force

mixlogit prime_minister median_party prparty_direct if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3, rand(largest_party incumbentpm_party prparty_indirect) group(cabinet_id) nrep(200)
calcROC
estimates store model3
lrtest model3 model1, force

mixlogit prime_minister largest_party median_party prparty_reactive if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3, rand(incumbentpm_party prparty_proactive) group(cabinet_id) nrep(200)
calcROC
estimates store model4
lrtest model4 model1, force

mixlogit prime_minister median_party prparty_pro_direl prparty_re_direl prparty_re_parl if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3, rand (largest_party incumbentpm_party prparty_pro_parl) group(cabinet_id) nrep(200)
calcROC
estimates store model5
lrtest model5 model1, force


/* APPENDIX C, TABLE C4: 2 >= CD-INDEX  < 3, Independent PMs & Monarchies, post-1990 */

mixlogit prime_minister incumbentpm_party median_party if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & start_year>=1990, rand(largest_party) group(cabinet_id) nrep(200)
calcROC
estimates store model1

mixlogit prime_minister incumbentpm_party median_party prparty if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & start_year>=1990, rand(largest_party) group(cabinet_id) nrep(200)
calcROC
estimates store model2
lrtest model2 model1, force

mixlogit prime_minister incumbentpm_party median_party prparty_direct prparty_indirect if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & start_year>=1990, rand(largest_party) group(cabinet_id) nrep(200)
calcROC
estimates store model3
lrtest model3 model1, force

mixlogit prime_minister incumbentpm_party prparty_reactive if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & start_year>=1990, rand(largest_party median_party prparty_proactive) group(cabinet_id) nrep(200)
calcROC
estimates store model4
lrtest model4 model1, force

mixlogit prime_minister incumbentpm_party prparty_pro_direl prparty_re_direl prparty_re_parl if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >= 2 & cd_index < 3 & start_year>=1990, rand (largest_party median_party prparty_pro_parl) group(cabinet_id) nrep(200)
calcROC
estimates store model5
lrtest model5 model1, force


/* APPENDIX C, TABLE C5:  CD-INDEX >= 3, Independent PMs & Monarchies */

mixlogit prime_minister largest_party median_party if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3, rand(incumbentpm_party) group(cabinet_id) nrep(200)
calcROC
estimates store model1

mixlogit prime_minister largest_party median_party  if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3, rand(incumbentpm_party prparty) group(cabinet_id) nrep(200)
calcROC
estimates store model2
lrtest model2 model1, force

mixlogit prime_minister largest_party median_party prparty_indirect if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3, rand(incumbentpm_party prparty_direct) group(cabinet_id) nrep(200)
calcROC
estimates store model3
lrtest model3 model1, force

mixlogit prime_minister largest_party median_party  if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3, rand(incumbentpm_party prparty_proactive prparty_reactive) group(cabinet_id) nrep(200)
calcROC
estimates store model4
lrtest model4 model1, force

mixlogit prime_minister largest_party prparty_pro_parl prparty_re_parl if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3, rand (incumbentpm_party median_party prparty_pro_direl prparty_re_direl) group(cabinet_id) nrep(200)
calcROC
estimates store model5
lrtest model5 model1, force


/* APPENDIX C, TABLE C6:  CD-INDEX >= 3, Independent PMs & Monarchies, post-1990 */

mixlogit prime_minister largest_party median_party if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & start_year>=1990, rand(incumbentpm_party) group(cabinet_id) nrep(200)
calcROC
estimates store model1

mixlogit prime_minister prparty if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & start_year>=1990, rand(largest_party incumbentpm_party median_party) group(cabinet_id) nrep(200)
calcROC
estimates store model2
lrtest model2 model1, force

mixlogit prime_minister largest_party prparty_direct prparty_indirect if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & start_year>=1990, rand(incumbentpm_party median_party) group(cabinet_id) nrep(200)
calcROC
estimates store model3
lrtest model3 model1, force

mixlogit prime_minister largest_party median_party prparty_proactive prparty_reactive if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & start_year>=1990, rand(incumbentpm_party) group(cabinet_id) nrep(200)
calcROC
estimates store model4
lrtest model4 model1, force

mixlogit prime_minister largest_party median_party prparty_pro_direl prparty_re_direl prparty_pro_parl prparty_re_parl if caretaker==0 & cabmajparty==0 & pr_nonparty==0 & hos_interim==0 & cd_index >=3 & start_year>=1990, rand (incumbentpm_party) group(cabinet_id) nrep(200)
calcROC
estimates store model5
lrtest model5 model1, force
